home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / toolpack.000 / toolpack / toolpack1.2 / scriptsource / cname.s < prev    next >
Encoding:
Text File  |  1993-10-04  |  9.9 KB  |  338 lines

  1. #! /bin/csh
  2. #  cname is a csh script to change program names and function generally
  3. #  as a Fortran-intelligent stream editor, using ISTCN and ISTCR.
  4. #
  5. #
  6. #  Invocation:
  7. #
  8. #  cname Polish_option_file command_file_1 command_file_2 Fortran_source_file
  9. #
  10. #  Polish_option_file is the name of a file containing Polish options used in
  11. #  reconstructing the transformed Fortran.  If Polish_option_file is "-"
  12. #  then default Polish options will be used.
  13. #
  14. #  command_file_1 and command_file_2 are the names of command files for
  15. #  ISTCN and ISTCR, respectively.  If one or the other is not supplied,
  16. #  its place in the command line must be occupied by "-".
  17. #
  18. #  Check command line validity.
  19. if ( $#argv < 4 ) then
  20. TOOLPACKPATH/toolpack1.2/util/echoerr \
  21. Invocation:
  22. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  23. TOOLPACKPATH/toolpack1.2/util/echoerr \
  24. cname Polish_option_file command_file_1 command_file_2 Fortran_source_file
  25. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  26. TOOLPACKPATH/toolpack1.2/util/echoerr \
  27. 'Polish_option_file is created by using script "polx".'
  28. TOOLPACKPATH/toolpack1.2/util/echoerr \
  29. '"-" in place of Polish_option_file gives default Polish options.'
  30. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  31. TOOLPACKPATH/toolpack1.2/util/echoerr \
  32. command_file_1 and command_file_2 are the names of command files containing
  33. TOOLPACKPATH/toolpack1.2/util/echoerr \
  34. scan-related changes and attribute-related changes, respectively.  If one
  35. TOOLPACKPATH/toolpack1.2/util/echoerr \
  36. or the other is not supplied, its place in the command line must be occupied
  37. TOOLPACKPATH/toolpack1.2/util/echoerr \
  38. 'by "-".' For information about command files refer to Users\' Guide.
  39. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  40. TOOLPACKPATH/toolpack1.2/util/echoerr \
  41. Transformed code is sent to standard output and may be redirected to a file.
  42. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  43.    exit
  44. endif
  45. #  "-" as Polish_option_file gives default options.
  46. if ( $1 != - ) then
  47. #  Check that Polish_option_file exists.
  48.    if ( -e $1 == 0 ) then
  49. TOOLPACKPATH/toolpack1.2/util/echoerr \
  50. "'$1' does not exist."
  51.       exit
  52.    endif
  53. endif
  54. if ( $2 != - ) then
  55. #  Check that command_file_1 exists.
  56.    if ( -e $2 == 0 ) then
  57. TOOLPACKPATH/toolpack1.2/util/echoerr \
  58. "'$2' does not exist."
  59.       exit
  60.    endif
  61. endif
  62. if ( $3 != - ) then
  63. #  Check that command_file_2 exists.
  64.    if ( -e $3 == 0 ) then
  65. TOOLPACKPATH/toolpack1.2/util/echoerr \
  66. "'$3' does not exist."
  67.       exit
  68.    endif
  69. endif
  70. #  Check that Fortran_source_file exists.
  71. if ( -e $4 == 0 ) then
  72. TOOLPACKPATH/toolpack1.2/util/echoerr \
  73. "'$4' does not exist."
  74.    exit
  75. endif
  76. #
  77. #  Create PFS.  If PFS already exists, exit with an advisory message.
  78. #
  79. if ( -e _.TOOLPACK == 0 ) then
  80.    mkdir _.TOOLPACK
  81. else
  82. TOOLPACKPATH/toolpack1.2/util/echoerr \
  83. Toolpack-created directory '"_.TOOLPACK"' exists. \
  84. Remove with script '"discard"'.
  85.    exit
  86. endif
  87. #  Make a tab-free copy of the Fortran source and use it as source.
  88. set src = src$$
  89. expand $4 > _.TOOLPACK/$src
  90. #  ISTCN command file name.
  91. set com1 = com1$$
  92. #  ISTCR command file name.
  93. set com2 = com2$$
  94. #  ISTPL option file name.
  95. if ( $1 == - ) then
  96.    set polopts = -
  97. else
  98.    set polopts = \#$1
  99. endif
  100. #
  101. if ( ( $2 != - ) && ( $3 != - ) ) then
  102. #
  103. #  Case 1: Both command files are supplied.  Sequence of invocations is
  104. #  ISTCN (source in, tokens out, commands prepended to command file), ISTYP,
  105. #  ISTCR (case folding command prepended to command file), ISTYF, ISTPL.
  106. #
  107. #  Token file name.
  108.    set tkn = tkn$$
  109. #  Comment file name.
  110.    set cmt = cmt$$
  111. #  Prepend directives for source in, tokens out, to command_file_1.
  112.    echo '<source' > _.TOOLPACK/$com1
  113.    echo '>token' >> _.TOOLPACK/$com1
  114.    cat $2 >> _.TOOLPACK/$com1
  115. #  Create the interprocess file IST.CMD and append parameters for ISTCN.
  116. TOOLPACKPATH/toolpack1.2/util/mkipf \
  117. $com1 $src $tkn $cmt
  118. #
  119. #  Invoke ISTCN.
  120. #
  121. TOOLPACKPATH/toolpack1.2/exec/istcn.u
  122. #
  123. #  Exit if tool terminated with errors.
  124.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  125. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  126. TOOLPACKPATH/toolpack1.2/util/echoerr \
  127. Errors detected.  Script terminated.
  128. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  129.       /bin/rm -r _.TOOLPACK
  130.       exit
  131.    endif
  132. #  Parse tree file name.
  133.    set tree = tree$$
  134. #  Symbol table file name (from ISTYP).
  135.    set table = table$$
  136. #  Comment index file name.
  137.    set index = index$$
  138. #  Create the interprocess file IST.CMD and append parameters for ISTYP.
  139. TOOLPACKPATH/toolpack1.2/util/mkipf \
  140. $tkn $cmt $tree $table $index
  141. #
  142. #  Invoke ISTYP.
  143. #
  144. TOOLPACKPATH/toolpack1.2/exec/istyp.u
  145. #
  146. #  Exit if tool terminated with errors.
  147.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  148. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  149. TOOLPACKPATH/toolpack1.2/util/echoerr \
  150. Errors detected.  Script terminated.
  151. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  152.       /bin/rm -r _.TOOLPACK
  153.       exit
  154.    endif
  155. #  Prepend directive for case folding to command_file_2.
  156.    echo '%f' > _.TOOLPACK/$com2
  157.    cat $3 >> _.TOOLPACK/$com2
  158. #  Symbol table file name (from ISTCR).
  159.    set tblout = tout$$
  160. #  Create the interprocess file IST.CMD and append parameters for ISTCR.
  161. TOOLPACKPATH/toolpack1.2/util/mkipf \
  162. $table $tblout $com2
  163. #
  164. #  Invoke ISTCR.
  165. #
  166. TOOLPACKPATH/toolpack1.2/exec/istcr.u
  167. #
  168. #  Exit if tool terminated with errors.
  169.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  170. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  171. TOOLPACKPATH/toolpack1.2/util/echoerr \
  172. Errors detected.  Script terminated.
  173. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  174.       /bin/rm -r _.TOOLPACK
  175.       exit
  176.    endif
  177. #  Output token stream file.
  178.    set tknout = ytkn$$
  179. #  Output comment stream file.
  180.    set cmtout = ycmt$$
  181. #  Create the interprocess file IST.CMD and append parameters for ISTYF.
  182. TOOLPACKPATH/toolpack1.2/util/mkipf \
  183. $tree $tblout $index $cmt $tknout $cmtout
  184. #
  185. #  Invoke ISTYF.
  186. #
  187. TOOLPACKPATH/toolpack1.2/exec/istyf.u
  188. #
  189. #  Exit if tool terminated with errors.
  190.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  191. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  192. TOOLPACKPATH/toolpack1.2/util/echoerr \
  193. Errors detected.  Script terminated.
  194. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  195.       /bin/rm -r _.TOOLPACK
  196.       exit
  197.    endif
  198. #  Create the interprocess file IST.CMD and append parameters for ISTPL.
  199. TOOLPACKPATH/toolpack1.2/util/mkipf \
  200. $tknout $cmtout \#1 $polopts
  201. #
  202. TOOLPACKPATH/toolpack1.2/exec/istpl.u
  203. #
  204. else if ( ( $2 != - ) && ( $3 == - ) ) then
  205. #
  206. #  Case 2: First command file is supplied but not the second.  Invocation
  207. #  is ISTCN (source in, source out, commands prepended to command file).
  208. #
  209. #  Output file name (not stdout immediately lest the output be mixed
  210. #  with messages).
  211.    set outq = outq$$
  212. #  Prepend directives for source in, source out, to command_file_1.
  213.    echo '<source' > _.TOOLPACK/$com1
  214.    echo '>source' >> _.TOOLPACK/$com1
  215.    cat $2 >> _.TOOLPACK/$com1
  216. #  Create the interprocess file IST.CMD and append parameters for ISTCN.
  217. TOOLPACKPATH/toolpack1.2/util/mkipf \
  218. $com1 $src $outq $polopts
  219. #
  220. #  Invoke ISTCN.
  221. #
  222. TOOLPACKPATH/toolpack1.2/exec/istcn.u
  223. #
  224. #  Exit if tool terminated with errors.
  225.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  226. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  227. TOOLPACKPATH/toolpack1.2/util/echoerr \
  228. Errors detected.  Script terminated.
  229. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  230.       /bin/rm -r _.TOOLPACK
  231.       exit
  232.    endif
  233.    cat _.TOOLPACK/$outq
  234. #
  235. else if ( ( $2 == - ) && ( $3 != - ) ) then
  236. #
  237. #  Case 3: Second command file is supplied but not the first.  Sequence
  238. #  of invocations is ISTLY, ISTCR (case folding command prepended to
  239. #  command file), ISTYF, ISTPL.
  240. #
  241. #  Comment file name.
  242.    set cmt = cmt$$
  243. #  Parse tree file name.
  244.    set tree = tree$$
  245. #  Symbol table file name.
  246.    set table = table$$
  247. #  Comment index file name.
  248.    set index = index$$
  249. #  Create the interprocess file IST.CMD and append parameters for ISTLY.
  250. TOOLPACKPATH/toolpack1.2/util/mkipf \
  251. $src $cmt $tree $table $index
  252. #
  253. #  Invoke ISTLY.
  254. #
  255. TOOLPACKPATH/toolpack1.2/exec/istly.u
  256. #
  257. #  Exit if tool terminated with errors.
  258.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  259. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  260. TOOLPACKPATH/toolpack1.2/util/echoerr \
  261. Errors detected.  Script terminated.
  262. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  263.       /bin/rm -r _.TOOLPACK
  264.       exit
  265.    endif
  266. #  Prepend directive for case folding to command_file_2.
  267.    echo '%f' > _.TOOLPACK/$com2
  268.    cat $3 >> _.TOOLPACK/$com2
  269. #  Symbol table file name (from ISTCR).
  270.    set tblout = tout$$
  271. #  Create the interprocess file IST.CMD and append parameters for ISTCR.
  272. TOOLPACKPATH/toolpack1.2/util/mkipf \
  273. $table $tblout $com2
  274. #
  275. #  Invoke ISTCR.
  276. #
  277. TOOLPACKPATH/toolpack1.2/exec/istcr.u
  278. #
  279. #  Exit if tool terminated with errors.
  280.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  281. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  282. TOOLPACKPATH/toolpack1.2/util/echoerr \
  283. Errors detected.  Script terminated.
  284. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  285.       /bin/rm -r _.TOOLPACK
  286.       exit
  287.    endif
  288. #  Output token stream file.
  289. set tknout = ytkn$$
  290. #  Output comment stream file.
  291. set cmtout = ycmt$$
  292. #  Create the interprocess file IST.CMD and append parameters for ISTYF.
  293. TOOLPACKPATH/toolpack1.2/util/mkipf \
  294. $tree $tblout $index $cmt $tknout $cmtout
  295. #
  296. #  Invoke ISTYF.
  297. #
  298. TOOLPACKPATH/toolpack1.2/exec/istyf.u
  299. #
  300. #  Exit if tool terminated with errors.
  301.    if ( `cat _.TOOLPACK/_.info` == -1 ) then
  302. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  303. TOOLPACKPATH/toolpack1.2/util/echoerr \
  304. Errors detected.  Script terminated.
  305. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  306.       /bin/rm -r _.TOOLPACK
  307.       exit
  308.    endif
  309. #  Create the interprocess file IST.CMD and append parameters for ISTPL.
  310. TOOLPACKPATH/toolpack1.2/util/mkipf \
  311. $tknout $cmtout \#1 $polopts
  312. #
  313. #  Invoke ISTPL.
  314. #
  315. TOOLPACKPATH/toolpack1.2/exec/istpl.u
  316. #
  317. else
  318. #
  319. #  Case 4: Neither command file is supplied.  In this case the script
  320. #  cname has the same effect as pol (invokes ISTLP).
  321. #
  322. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  323. TOOLPACKPATH/toolpack1.2/util/echoerr \
  324. No command files supplied -- cname has the same effect as pol.
  325. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  326. #  Create the interprocess file IST.CMD and append parameters for ISTLP.
  327. TOOLPACKPATH/toolpack1.2/util/mkipf \
  328. $src \#1 $polopts
  329. #
  330. #  Invoke ISTLP.
  331. #
  332. TOOLPACKPATH/toolpack1.2/exec/istlp.u
  333. #
  334. endif
  335. #
  336. /bin/rm -r _.TOOLPACK
  337. #
  338.